//////// JQUERY EVENTS

$(document).ready(function() {
  
  hideAllSections();
  showSection($("#nav a.initial-item")); 
  
  $("span.code").addClass("not-hovering");
  
  $("span.code").click(function() {
    var shellFrame = window.parent;
    var thisText = $(this).text();
    shellFrame.FikaShell.enter(thisText);
  });
  
  $("span.code").hover(
    function() {
      $(this).removeClass("not-hovering");
      $(this).addClass("hovering");
    },
    function() {
      $(this).addClass("not-hovering");
      $(this).removeClass("hovering");
    }
  );
  
  $("#nav a").click(function() {
    showSection($(this));
    return false;
  });
  
  function showSection(navItem) {
    var sectionToDisplay = navItem.attr("href");
    hideAllSections();
    $(sectionToDisplay).show();
    navItem.addClass("selected");
  }
  
  function hideAllSections() {
    $("div#sections div").hide();
    $("#nav a").removeClass("selected");
  }

});